package com.ponhu.ea2.stockcenter.provider.service.entity.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ponhu.ea2.stockcenter.provider.entity.TemStockDifference;
import com.ponhu.ea2.stockcenter.provider.mapper.TemStockDifferenceMapper;
import com.ponhu.ea2.stockcenter.provider.service.entity.TemStockDifferenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ponhu.ea2.stockcenter.provider.utils.ProBeanUtils;
import com.ponhu.ea2.stockcenter.vo.TemStockDifferenceVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class TemStockDifferenceServiceImpl
        extends ServiceImpl<TemStockDifferenceMapper, TemStockDifference>
        implements TemStockDifferenceService {

    public List<TemStockDifferenceVo> exportTemStockDifferenceVo(String whHas, String jwHas) {
        LambdaQueryWrapper<TemStockDifference> queryWrapper = Wrappers
                .lambdaQuery(TemStockDifference.class)
                .eq(TemStockDifference::getWhHas, whHas)
                .eq(TemStockDifference::getJwHas, jwHas);

        return list(queryWrapper).stream()
                .map(diff -> ProBeanUtils.copyProperties(diff, TemStockDifferenceVo.class))
                .collect(Collectors.toList());
    }
}
